<!--
=============================================================
WebIntelligence(r) Report Panel
Copyright(c) 2001-2005 Business Objects S.A.
All rights reserved

Use and support of this software is governed by the terms
and conditions of the software license agreement and support
policy of Business Objects S.A. and/or its subsidiaries. 
The Business Objects products and technology are protected
by the US patent number 5,555,403 and 6,247,008

=============================================================
--><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script language="javascript" src="../../../../dhtmllib/dom.js"></script>
<script language="javascript" src="../../../../dhtmllib/menu.js"></script>
<script language="javascript" src="../../../../dhtmllib/palette.js"></script>
<script language="javascript" src="../../../../dhtmllib/treeview.js"></script>
<script language="javascript" src="../../../scripts/CommonWom.js"></script>
<script language="javascript">
p = parent
initDom("../../../../dhtmllib/images/"+p._skinName+"/", p._lang)
initTooltipWin(p)
p.setKeyCB(this, false)
</script>     
<script language="javascript">styleSheet()</script>
<script language="javascript">
_displayBarYOffset = 27;
dirImg = getBasePath()+'../../../images/main/'
curIcon="formula.gif"
_img = '../../../images/main/'
_useVariables = p.isEnableUserRight(p._usrUseFormula)
displayDictIcn = new_IconMenuWidget({id:"displayDictMenu",text:"排列依据"});
displayDictMenu=displayDictIcn.getMenu();
displayDictMenu.addCheck("disByAlpha","字母顺序", updateDisplayCB);
displayDictMenu.addCheck("disByDP","查询", updateDisplayCB);
resultObjectsContextMenu=p.new_MenuWidget({id:"resultObjectsContextMenu",beforeShowCB:initResultObjectsContextMenu})
addContextMenu=resultObjectsContextMenu.add("dictAddC","新建", addFormulaCB,dirImg+"formula.gif",5*16,0, false, null, 16);
editContextMenu=resultObjectsContextMenu.add("dictEditC","编辑", editFormulaCB,dirImg+"formula.gif",6*16,0, false, null, 16);
mergeContextMenu=resultObjectsContextMenu.add("mergeC","合并", mergeCB, dirImg+"formula.gif",7*16,0, false, null,16 ); 
unmergeContextMenu=resultObjectsContextMenu.add("unmergeC","取消合并", mergeCB);
mergePropContextMenu=resultObjectsContextMenu.add("mergePropC","编辑属性", mergePropCB);
svContextMenu=resultObjectsContextMenu.add("showValuesC","Show Values", null );
resultObjectsContextMenu.addSeparator();
rmContextMenu=resultObjectsContextMenu.add("dictRemoveC","删除", rmFormulaCB, dirImg+"formula.gif",1*16,0,false, null, 16);
dicTree = new_TreeWidget({id:'dicTree'
, w:160
, h:280
, icns:dirImg + "qualificationIcons.gif"
, clickCB:clickCB
, doubleClickCB:dclickCB
, bgClass: "panelzone"
, deleteCB : deleteCB
, searchZone: true
})
dicTree.borderW=0
dicTree.setTooltipOnMouseOver(true) 
dicTree.setMultiSelection(true)
dicTree.setDragDrop(startDragCB,acceptDropCB,dropCB,dragEndCB)
if (p.isEnableUserRight(p._usrShowRightClickMenu)) {
dicTree.setRightClickMenuCB(showContextMenu)
}
function initResultObjectsContextMenu()
{
var isVariable=false, isMergeObject=false, isMonoSel=false, canMerge=false, canShowValues=false, canAddVariable=false;
var sels=dicTree.getSelections(), len=sels.length;
if(len == 1) 
{
var sel = sels[0];
_data=sel.userData
if (_data) 
{
if (_data.isVariable) 
{
isVariable = true;
canAddVariable=true;
}
if(_data.kind && _data.kind==_linkDim)
isMergeObject=true;
if(sel.variableFolder)
canAddVariable=true;
} 
}
else 
{
canMerge=p.md_canMergeDims(sels);
}
addContextMenu.setDisplay(canAddVariable);
editContextMenu.setDisplay(isVariable);
mergePropContextMenu.setDisplay(isMergeObject);
mergeContextMenu.setDisplay(canMerge);
unmergeContextMenu.setDisplay(isMergeObject);
rmContextMenu.setDisplay(isVariable) 
svContextMenu.setDisplay(canShowValues);
}
        function clickCB()
        {
p.escapeFormatPainter()
currentIconId=0
removeGrayStyle(dicTree.sub[0]); 
var items = dicTree.getSelections()
        if (items.length == 1) 
{
_singleSel = items[0]
currentIconId = items[0].iconId
var data = _singleSel.userData
if (_singleSel && data && data.kind && !(data.isVariable) && !(data.kind == _msr)) 
{
var link = getLinkedObject(data);
setIncompatibleObjects(dicTree.sub[0],link?link.DPNames:new Array(data.dpName));
}
}
        }
function setIncompatibleObjects(node,arrDPNames)
{
var len = node.sub.length, item=null
    for (var j = 0; j < len; j++) 
{
item = node.sub[j]
var obj = item.userData;
if ((obj != null) && (obj.kind != null) && (obj.kind != _msr) && !(obj.isVariable) && !(obj.isStripped)) 
{
var link = getLinkedObject(obj)
var arr = link ? link.DPNames : new Array(obj.dpName);
if (!arrayIntersection(arrDPNames, arr)) 
item.setGrayStyle(true);
}
if (item.sub.length) 
setIncompatibleObjects(item, arrDPNames)
}
}
function removeGrayStyle(node)
{
var len = node.sub.length
    for (var j = 0; j < len; j++) 
{
var obj = node.sub[j];
if (!obj.userData.isStripped) { 
obj.setGrayStyle(false)
}
if (obj.sub.length) 
removeGrayStyle(obj);
}
}
function arrayIntersection(arr1,arr2)
{
for(var i=0;i<arr1.length;i++)
if(arr2.indexOf(arr1[i])>-1) 
return true;
return false;
}
function getLinkedObject(obj)
{
if(obj.kind == _linkDim) return obj; 
if (obj.parLinkId) 
{
var elem = dicTree.findInData(obj.parLinkId, "id");
if (elem) return elem.userData;
}
if(obj.hasNoLink) return null;
var links = p._dictionaryStructure.byQuery.Links
if(links)
{
var len= links.length
for(var i=0;i<len;i++)
{
var arr = links[i].children;
for(var j=0;j<arr.length;j++)
{
if (obj.id == arr[j].id) 
{
var elem =  dicTree.findInData(links[i].id,"id");
obj.parLinkId = links[i].id; 
return elem.userData;
}
}
}
}
obj.hasNoLink=true;
return null;
}
        function loadCB()
        {
resultObjectsContextMenu.init();
p.initUserRight(resultObjectsContextMenu,p._usrUseFormula);
displayDictIcn.init();
dicTree.init();
updateDisplayCB("dp"); 
resizeCB()
setSmartResizeHandler(resizeCB)
p.hideBlockWhileWaitWidget();
    }
    function startDragCB()
    {
var pos = p.workbenchW.getPerspective().getLeftPaneCoordinates();
setTooltipOffset(pos.x,pos.y)
p._accepDDfunc=p.Report_AcceptDropCB
p._dropDDfunc=p.Report_DropCB
p._currentfeedIdref = null
p._currentSelectedKind = null
p._currentfeedId = null
    }
    function dragEndCB()
    {
p._accepDDfunc=null
p._dropDDfunc=null
fr=getTopFrameset(self).getReportFrame(),d=fr.document
p.showFeedbackElem(d,false)
p.clearDrawnFeeds()
    }
    function acceptDropCB()
    {
return false
    }
    function dropCB()
    {
    }
function dclickCB(data)
{
p.escapeFormatPainter()
if (!(data)) return false
if (data.isVariable) 
{
if (p.isEnableUserRight(p._usrUseFormula))
editFormulaCB()
} else if (data.DPNames) {
if (p.isEnableUserRight(p._usrCreateMergeDimension))
mergePropCB(data)
}
return false
}
    function editFormulaCB()
    {
p.escapeFormatPainter()
p.formulaEdition=true
p.wt()
p.frameNav('DlgFrame',p._root+'language/' + p._lang + '/html/variableEditorDialog.html?fromLPane=yes')
    }
    function rmFormulaCB()
    {        
p.escapeFormatPainter()
        p.showPromptDialog("确实要删除此变量吗？" , "删除变量", p._promptDlgWarning,doRmFormula)
    }
    function deleteCB(data)
    {    
if (data && data.isVariable)
{
if (p.isEnableUserRight(p._usrUseFormula))
rmFormulaCB()
}
    }
    function doRmFormula()
    {        
var selItems = dicTree.getSelections()
var data=selItems[0].userData,n=data.name
p.eventManager.notify(p._EVT_VARS_UPDATE)
var url = p._root + "processFormulaDeletion" + p._appExt
url += p.urlParams(false, true) 
url += "&sName=" + p.convURL(n)
p.wt()
p.frameNav('Report',url)
    }
    function addFormulaCB()
    {
p.escapeFormatPainter()
p.formulaEdition=false
p.wt()
p.frameNav('DlgFrame',p._root+'language/' + p._lang + '/html/variableEditorDialog.html?fromLPane=yes')
    }
mergeAction=null
selID=null
selName=null
selDesc=null
arraySources=new Array
_data= null
function mergePropCB(data)
{
data = data?data:_data
selID=data.id
selName=data.name
selDesc=data.desc
if (!(window._singleSel)) return
var list = _singleSel.sub, len=list.length
for (var i = 0; i < len; i++) {
var subData = list[i].userData
arraySources[i]={id:subData.id,
name:subData.name+" ("+subData.dpName+")",
desc:subData.desc}
}
p.frameNav('DlgFrame',p._root+'language/' + p._lang + '/html/mergeDimPropertiesDialog.html')
}
    function mergeCB()
    {
p.escapeFormatPainter()
mergeAction=(this.id=="mergeC")?"merge":"unmerge"
if (mergeAction=="merge") 
processMerge();
else 
p.showPromptDialog("如果删除此合并维，则会从报表中删除它的所有实例。是否确实要继续？","删除合并维",p._promptDlgWarning, processMerge, null);
}
function processMerge()
{
var sels = dicTree.getSelections();
p.md_processMergeDims(mergeAction, sels);
mergeAction= null;
    }
    function resizeCB()
    {
dicTree.resize( Math.max(0,winWidth()), Math.max(0,winHeight()- _displayBarYOffset))
    }
function writeMyBody()
{
var s = new Array()
var i=0
s[i++] = dicTree.getHTML()
s[i++] = '<div class="toolbarBackgnd" height='+_displayBarYOffset+'>' +displayDictIcn.getHTML()+'</div>'
document.write(s.join(""))
}
function showContextMenu(id, ev)
{
p.escapeFormatPainter()
var pos = p.workbenchW.getPerspective().getLeftPaneCoordinates(),x,y
ev = _ie?_curWin.event:ev
x=absxpos(ev)+pos.x
y=absypos(ev)+pos.y
resultObjectsContextMenu.show(true,x,y)
}
    function lPaneContextMenu()
{
return false;
}
function updateDisplayCB(display)
{ 
if(display==null)
{
display = (this.id == "disByAlpha" )?"alpha":"dp";
}
p.fillDictionaryTree(dicTree,self,display);
displayDictIcn.setText("排列依据" +((display=="dp")?" 查询":" 字母顺序"));
displayDictMenu.getItemByID("disByDP").check((display=="dp"));
displayDictMenu.getItemByID("disByAlpha").check(!(display=="dp"));
}
</script>        
</head>
<body class="panelzone"  style="overflow:hidden;" marginheight="0" marginwidth="0" leftmargin="0" topmargin="0" onLoad="loadCB();"  oncontextmenu="return lPaneContextMenu();">
<script language="javascript">writeMyBody()</script>
<form target="Report" style="display:none" name="formulaForm" method="post" action="">
<input type="hidden" name="sNewVarIds" id="sNewVarIds">
</form>
</body>
</html>
